package com.ssy.lingxi.logistics.api.feign;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.logistics.api.dto.request.OrderFreightRequest;
import com.ssy.lingxi.logistics.api.dto.request.OrderSeparateFreightListRequest;
import com.ssy.lingxi.logistics.api.dto.request.TransferOrderFreightRequest;
import com.ssy.lingxi.logistics.api.dto.response.FreightResponse;
import com.ssy.lingxi.logistics.api.dto.response.OrderSeparateFreightListResponse;
import com.ssy.lingxi.logistics.api.fallback.FreightRemoteControllerFeignFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.List;

/**
 * @menu 内部服务 - 运费模板
 * @author yzc
 * @version 2.0.0
 * @date 2020/7/10
 */
@FeignClient(name = "logistics-service", fallback = FreightRemoteControllerFeignFallback.class)
public interface FreightRemoteControllerFeign {


    /**
     * 运费计算
     * @param request 接口参数
     * @return 返回结果
     */
    @PostMapping(value = "/logistics/freightRemote/calFreightPrice")
    Wrapper<BigDecimal> calFreightPrice(@RequestBody @Validated OrderFreightRequest request);

    /**
     * 订单转单功能 - 新增收货地址及运费计算
     * @param requestList 接口参数
     * @return 返回结果
     */
    @PostMapping(value = "/logistics/freightRemote/calFreightPrice/batch")
    Wrapper<List<FreightResponse>> batchCalFreightPrice(@RequestBody @Validated List<TransferOrderFreightRequest> requestList);

    /**
     * 批量查询运费（拆单）
     * @param requests 拆单后的商品信息列表
     * @return 查询结果
     */
    @PostMapping(value = "/logistics/freightRemote/calFreightPrice/separateOrder")
    Wrapper<List<OrderSeparateFreightListResponse>> findSeparateOrderFreight(@RequestBody @Valid List<OrderSeparateFreightListRequest> requests);
}